package com.example.mybatisplus.config;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.SystemMetaObject;
import org.springframework.stereotype.Component;

import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @Author deyou
 * @Date 2022/1/12 21:19
 * @Version 1.0
 */
@Slf4j
@Component
public class CustomIdGenerator implements IdentifierGenerator {

    private final AtomicLong al = new AtomicLong(1);

    /**
     * id 为Num 时重写实现自定义
     * @param entity
     * @return
     */
    @Override
    public Number nextId(Object entity) {
        long l = al.addAndGet(2);

        return null ;
    }
    /**
     * id 为String  时重写实现自定义
     * @param entity
     * @return
     */
    @Override
    public String nextUUID(Object entity) {

        return "Hello"+IdentifierGenerator.super.nextUUID(entity);
    }
}
